package com.ruoyi.edh.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.edh.domain.EdhShoppingAddress;
import com.ruoyi.edh.mapper.EdhShoppingAddressMapper;
import com.ruoyi.edh.service.IEdhShoppingAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 易订货-收货地址Service业务层处理
 * 
 * @author xxx
 * @date 2020-09-02
 */
@Service
public class EdhShoppingAddressServiceImpl implements IEdhShoppingAddressService
{
    @Autowired
    private EdhShoppingAddressMapper edhShoppingAddressMapper;

    /**
     * 查询易订货-收货地址
     * 
     * @param id 易订货-收货地址ID
     * @return 易订货-收货地址
     */
    @Override
    public EdhShoppingAddress selectEdhShoppingAddressById(Long id)
    {
        return edhShoppingAddressMapper.selectEdhShoppingAddressById(id);
    }

    /**
     * 查询易订货-收货地址列表
     * 
     * @param edhShoppingAddress 易订货-收货地址
     * @return 易订货-收货地址
     */
    @Override
    public List<EdhShoppingAddress> selectEdhShoppingAddressList(EdhShoppingAddress edhShoppingAddress)
    {
        return edhShoppingAddressMapper.selectEdhShoppingAddressList(edhShoppingAddress);
    }

    /**
     * 新增易订货-收货地址
     * 
     * @param edhShoppingAddress 易订货-收货地址
     * @return 结果
     */
    @Override
    public int insertEdhShoppingAddress(EdhShoppingAddress edhShoppingAddress)
    {
        if (0==edhShoppingAddress.getSort()){
            edhShoppingAddressMapper.updateSortByUserId(SecurityUtils.getUserId(),"99");
        }
        edhShoppingAddress.setCreateTime(DateUtils.getNowDate());
        edhShoppingAddress.setCreateBy(SecurityUtils.getUserId()+"");
        return edhShoppingAddressMapper.insertEdhShoppingAddress(edhShoppingAddress);
    }

    /**
     * 修改易订货-收货地址
     * 
     * @param edhShoppingAddress 易订货-收货地址
     * @return 结果
     */
    @Override
    public int updateEdhShoppingAddress(EdhShoppingAddress edhShoppingAddress)
    {
        if (0==edhShoppingAddress.getSort()){
            edhShoppingAddressMapper.updateSortByUserId(SecurityUtils.getUserId(),"99");
        }
        edhShoppingAddress.setUpdateTime(DateUtils.getNowDate());
        return edhShoppingAddressMapper.updateEdhShoppingAddress(edhShoppingAddress);
    }

    /**
     * 批量删除易订货-收货地址
     * 
     * @param ids 需要删除的易订货-收货地址ID
     * @return 结果
     */
    @Override
    public int deleteEdhShoppingAddressByIds(String[] ids)
    {
        return edhShoppingAddressMapper.deleteEdhShoppingAddressByIds(ids);
    }

    /**
     * 删除易订货-收货地址信息
     * 
     * @param id 易订货-收货地址ID
     * @return 结果
     */
    @Override
    public int deleteEdhShoppingAddressById(Long id)
    {
        return edhShoppingAddressMapper.deleteEdhShoppingAddressById(id);
    }
}
